package pjkanri.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pjkanri.dao.DAOException;
import pjkanri.entity.Project;
import pjkanri.service.ProjectService;

/**
 * Servlet implementation class ProjectListServlet
 */
@WebServlet("/projectlist")
public class ProjectListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		List<Project> projectList = null;
		
		try {
			projectList =  ProjectService.getProjectList();
		} catch (DAOException e) {
			e.printStackTrace();
		}
		
		request.setAttribute("listproject", projectList);
		
		String forwardPath = "_projectList.jsp";

		// 転送処理
		request.getRequestDispatcher(forwardPath).forward(request, response);
	}

}
